<?php

namespace app\admin\validate;

use think\Validate;

class MenuValidate extends Validate
{
    protected $rule = [
        'sort' => 'integer',
        'parent_id' => 'require|integer',
        'type' => 'require',
        'title' => 'require|max:30',
        'icon' => 'max:255',
        'url' => 'max:100',
        'node' => 'max:100',
        'param' => 'max:100',
        'display' => 'require|in:0,1',
        'status' => 'require|in:0,1',
    ];


    protected $message = [
        'id.require' => '非法请求',
        'id.integer' => '非法请求',
        'sort.require' => '排序不能为空',
        'type.require' => '请选择菜单类型!',
        'title.require' => '请输入菜单标题!',
        'display' => '无效的状态值!',
        'status.in' => '无效的状态值!',
    ];

    public function sceneSwitch()
    {
        return $this->only(['id','status'])
                    ->append('id', 'require|integer');
    }

    public function sceneEdit()
    {
    	return $this->only(['id','sort','parent_id','type','title','icon','url','node','param','display','status'])
                    ->append('id', 'require|integer');
            
    }   
}